USE [SSB]
GO

--- Message Type ---
CREATE MESSAGE TYPE [http://ssbrouter/v10/Types/SSBArticleMsg] 
AUTHORIZATION [dbo] VALIDATION = WELL_FORMED_XML
GO

CREATE MESSAGE TYPE [http://ssbrouter/v10/Types/SSBPublishMsg] 
AUTHORIZATION [dbo] VALIDATION = WELL_FORMED_XML
GO


CREATE MESSAGE TYPE [http://ssbrouter/v10/Types/SSBSubscribeMsg] 
AUTHORIZATION [dbo] VALIDATION = WELL_FORMED_XML
GO


--- Contract ----
CREATE CONTRACT [http://ssbrouter/v10/SSBPublishContract] 
AUTHORIZATION [dbo] ([http://ssbrouter/v10/Types/SSBArticleMsg] SENT BY INITIATOR,
[http://ssbrouter/v10/Types/SSBPublishMsg] SENT BY INITIATOR)


GO
CREATE CONTRACT [http://ssbrouter/v10/SSBSubscribeContract] 
AUTHORIZATION [dbo] ([http://ssbrouter/v10/Types/SSBArticleMsg] SENT BY INITIATOR,
[http://ssbrouter/v10/Types/SSBSubscribeMsg] SENT BY INITIATOR)
GO

--- QUEUE ---
CREATE QUEUE [dbo].[http://ssbrouter/v10/SSBPubSubQueue] WITH STATUS = ON 
, RETENTION = OFF 
, ACTIVATION (  STATUS = ON 
				, PROCEDURE_NAME = [SSBPubSub].[usp_RoutingMsg] 
				, MAX_QUEUE_READERS = 5 
				, EXECUTE AS N'dbo'  ) ON [PRIMARY] 
GO

---- SERVICE ---

CREATE SERVICE [http://ssbrouter/v10/SSBPubSubService]  
AUTHORIZATION SSBRouterDbo  
ON QUEUE [dbo].[http://ssbrouter/v10/SSBPubSubQueue] 
([http://ssbrouter/v10/SSBPublishContract],
[http://ssbrouter/v10/SSBSubscribeContract])
GO

GRANT SEND ON SERVICE::[http://ssbrouter/v10/SSBPubSubService] TO Web001Dbo
GRANT SEND ON SERVICE::[http://ssbrouter/v10/SSBPubSubService] TO WMS001Dbo

GO

--- ROUTE ---
CREATE ROUTE [http://ssbrouter/v10/Web001/SSBPubSubRoute]    
WITH  SERVICE_NAME  = N'http://ssbrouter/v10/Web001/FromService' 
,  ADDRESS  = N'TCP://MPSERVER037:4174' 

CREATE ROUTE [http://ssbrouter/v10/WMS001/SSBPubSubRoute]    
WITH  SERVICE_NAME  = N'http://ssbrouter/v10/WMS001/FromService' 
,  ADDRESS  = N'TCP://DAZHESVR16:4174' 
